﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;
using Catering.View_Operaction;
using System.Data;

namespace Catering.Catering_Page.ShanShiFenXi
{
    public partial class MonthTotal_Percent : System.Web.UI.Page
    {
        // 属性注入
        private static View_Monitor vm = new View_Monitor();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.ReportViewer1.AsyncRendering = false;
                this.ReportViewer1.SizeToReportContent = false;
                this.ReportViewer1.ZoomMode = ZoomMode.Percent;
            }
        }

        protected void lbtn_Click(object sender, EventArgs e)
        {
            string AREAID = UCDDLToolWithYearOfMonth1.GetDDL_Area();
            string CLASSID = UCDDLToolWithYearOfMonth1.GetDDL_Class();
            DateTime DTIME = UCDDLToolWithYearOfMonth1.GetDateTime();
            if (DTIME.Year == 1949) return;
            int companyid = 0;
            if (Session["UserID"] != null)
            {
                string userid = Session["UserID"].ToString();
                companyid = new Catering_Rules.T_Personnel().GetCompanyIDByPID(Convert.ToInt32(userid));
            }
            string TITLE = Bind_Data_to_Controls.Bind_ReportTitle(AREAID, CLASSID, DTIME, "人均累计百分比");
            DataTable dt = vm.GetMonthOfCountAvg(companyid, AREAID, CLASSID, DTIME, TITLE);
            // 报表的数据源
            ReportDataSource rds = new ReportDataSource("DataSet1", dt);

            // 先清除报表数据源
            ReportViewer1.LocalReport.DataSources.Clear();

            // 绑定数据源
            ReportViewer1.LocalReport.DataSources.Add(rds);

            // 呈现出数据
            ReportViewer1.LocalReport.Refresh();
            ReportViewer1.Visible = true;
            //this.Label1.Text = string.Format("{0}年各班组月人均累计百分比", DTIME.Year);
            //this.Label1.Visible = true;
        }

        protected void lbtnChar_Click(object sender, EventArgs e)
        {
            string AREAID = UCDDLToolWithYearOfMonth1.GetDDL_Area();
            string CLASSID = UCDDLToolWithYearOfMonth1.GetDDL_Class();
            DateTime DTIME = UCDDLToolWithYearOfMonth1.GetDateTime();
            if (DTIME.Year == 1949) return;
            int companyid = 0;
            if (Session["UserID"] != null)
            {
                string userid = Session["UserID"].ToString();
                companyid = new Catering_Rules.T_Personnel().GetCompanyIDByPID(Convert.ToInt32(userid));
            }
            string Ttile = Bind_Data_to_Controls.Bind_ReportTitle(AREAID, CLASSID, DTIME, "人均累计百分比");
            ReportViewer2.LocalReport.ReportPath = @"Catering_Page\ShanShiFenXi\Report\MonthTotalPieChar.rdlc";
            DataTable dt = vm.GetMonthOfCountAvg(companyid, AREAID, CLASSID, DTIME, Ttile);
            ReportDataSource rds = new ReportDataSource("DataSet1", dt);
            ReportViewer2.LocalReport.DataSources.Clear();
            ReportViewer2.LocalReport.DataSources.Add(rds);
            ReportViewer2.LocalReport.Refresh();
        }
    }
}